package uk.ac.rothamsted;



public class BlastData implements Comparable<BlastData>, java.io.Serializable{

	private static final long serialVersionUID = 6403413247178820822L;
	public final String id1;
	public final String id2;
	public double score;
	public double overlap;
	public int idNum;

	public BlastData(double  setScore, double setOverlap, String id1, String id2, int setIdNum){
		score = setScore;
		overlap = setOverlap;
		this.id1 = id1;
		this.id2 = id2;
		idNum = setIdNum;
	}


	public double getScore(){
		return score;
	}

	public double getOverlap(){
		return overlap;
	}

	public int getIdNum(){
		return idNum;
	}

	@Override
	public int compareTo(BlastData arg0) {
		if(this.getScore() > arg0.getScore()){
			return 1;
		}else if(this.getScore() < arg0.getScore()){
			return -1;
		}else{
			return (arg0.idNum - this.idNum);
		}
	}

	public boolean equals(Object obj){
		if(obj instanceof BlastData){
			BlastData bd = (BlastData) obj;
			boolean compID1 = this.id1.equals(bd.id1);
			boolean compID2 = this.id2.equals(bd.id2);
			boolean compScore = this.score == bd.score;
			boolean compOverlap = this.overlap == bd.overlap;
			return compID1 && compID2 && compScore && compOverlap;
		}
		return false;

	}

	@Override
	public String toString(){
		return id1 + "  " + id2 + "  " + score + "  " + Math.round(overlap*100)/100.0 + "  " + idNum; 
	}

}
